/*
 * Copyright (c) 2006-2021, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2023-09-14     huger       the first version
 */
#include "bsp_adc.h"

#define DBG_TAG "adc"
#define DBG_LVL DBG_LOG
#include <rtdbg.h>

uint16_t adc_buff[ADC_BUFF_SIZE] = {0};

void bsp_adc_init(void)
{
    MX_DMA_Init(); //dma init
    MX_ADC1_Init();//adc init

//    HAL_NVIC_DisableIRQ(DMA2_Stream0_IRQn);

//    HAL_ADC_Start(&hadc1);
    HAL_ADC_Start_DMA(&hadc1, (uint32_t*)adc_buff, ADC_BUFF_SIZE);

    LOG_D("bsp_adc_init success");
}

void DMA2_Stream0_IRQHandler(void)
{
    HAL_DMA_IRQHandler(&hdma_adc1);
}


static int dbg_adc_info(int argc, char *argv[])
{
    LOG_I("adc_st[0] = %d,adc_st[1] = %d", adc_buff[0],adc_buff[1]);
    return RT_EOK;
}
MSH_CMD_EXPORT(dbg_adc_info, 获取adc信息);
